// tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    role:{
      type:String,
      value:"student", // student:学生，coach：教练
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    active: 0,
    list:[
      
    ],
    studentList:[
      {
				icon: 'home-o',
				text: '首页s',
				url: '/pages/tab-bar/student/home/home'
			},{
				icon: 'friends-o',
				text: '我的s',
				url: '/pages/tab-bar/student/mine/mine'
			},
    ],
    coachList:[
      {
				icon: 'home-o',
				text: '首页c',
				url: '/pages/tab-bar/coach/home/home'
			},{
				icon: 'friends-o',
				text: '我的c',
				url: '/pages/tab-bar/coach/mine/mine'
			},
    ]
  },

  attached(){
    const {role,studentList,coachList}=this.data;
    this.setData({
      list:role==='student'?studentList:coachList
    })
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      const {list}=this.data;
      const active=event.detail;
      this.setData({ active });
      this.triggerEvent("change",{
        active,
        list,
      })
      // wx.redirectTo({
      //   url:list[active].url
      // })
    },
    init() {
			const page = getCurrentPages().pop();
			this.setData({
				active: this.data.list.findIndex(item => item.url === `/${page.route}`)
			});
		}
  }
})
